﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Procure.Payment;

namespace Procure.Payment.Authorize
{
    public class AuthorizeGatewaySettings : IGatewaySettings
    {
        public string Version { get; private set; }

        public string LoginId { get; private set; }
        public string TransKey { get; private set; }

        public Uri Production { get; private set; }
        public Uri Test { get; private set; }

        public bool IsProduction { get; private set; }

        public AuthorizeGatewaySettings(Dictionary<string, string> Settings)
        {
            if (Settings.ContainsKey("Version"))
                LoginId = Settings["Version"];

            if (Settings.ContainsKey("LoginId"))
                LoginId = Settings["LoginId"];
            
            if (Settings.ContainsKey("TransKey"))
                TransKey = Settings["TransKey"];

            if (Settings.ContainsKey("IsProduction"))
                IsProduction = Settings["IsProduction"].ToLower().Trim() == "true";
            else
                IsProduction = false;

            if (Settings.ContainsKey("Production"))
                Production = new Uri(Settings["Production"]);
            else
                Test = new Uri("https://secure.authorize.net/gateway/transact.dll");

            if (Settings.ContainsKey("Test"))
                Test = new Uri(Settings["Test"]);
            else
                Test = new Uri("https://test.authorize.net/gateway/transact.dll");
        }
    }
}
